package live.jialing.sip.contact.employee.rest;

import live.jialing.core.web.controller.SimpleBaseRestController;
import live.jialing.sip.contact.employee.domain.EmployeeGroup;
import live.jialing.sip.contact.employee.service.EmployeeContactListService;
import live.jialing.structure.domain.Employee;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 机构内部通讯录的API
 */
@RestController
@RequestMapping(value = "/contact/employee/groups")
@Slf4j
public class EmployeeContactListRestController extends SimpleBaseRestController<EmployeeGroup, Long> {

    @Resource
    private EmployeeContactListService employeeContactListService;

    @Override
    public EmployeeContactListService getService() {
        return this.employeeContactListService;
    }

    /**
     * 获取指定分组的所有成员
     *
     * @param groupId 分组id
     * @return 员工集合
     */
    @RequestMapping(value = "/{groupId}/employees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<Employee> findEmployeeByGroup(@PathVariable("groupId") Long groupId) {

        return employeeContactListService.findGroupEmployeeByGroupId(groupId);
    }


}
